package com.linxi.handy.component.tab;

import com.linxi.handy.common.Constants;
import com.linxi.handy.util.FileUtils;

import javax.swing.*;
import java.awt.*;

/**
 * 选项卡窗格
 *
 * @author user
 */
public class TabbedPane extends JTabbedPane {
    /**
     * 头部标题
     */
    private final String TOP = "Welcome";
    /**
     * 主部分区域展示
     */
    public JTextArea mainTextArea = new JTextArea();
    /**
     * 头部栏
     */
    JScrollPane topPane = new JScrollPane();
    /**
     * 当前文本域的背景颜色
     */
    private Color textBackgroundColor = new Color(57, 105, 138);
    private Font tabFont = new Font("微软雅黑", 0, 10);
    private Color foreGround = new Color(100, 200, 250);

    public TabbedPane() {
        mainTextArea.setFont(Constants.DEFAULT_FONT_13);
        mainTextArea.setForeground(textBackgroundColor);
        mainTextArea.setText(FileUtils.readContentFromFile(Constants.INTRODUCE));
        mainTextArea.setEditable(false);
        topPane.setViewportView(mainTextArea);
        this.add(topPane, TOP);
        this.setFont(tabFont);
        this.setForeground(foreGround);
    }

    @Override
    public void add(Component component, Object constraints) {
        super.add(component, constraints);
        setTabComponentAt(indexOfTab((String) constraints), new ButtonTabComponent(this));
    }
}


